package com.bblocks.common.anti_reptile.service.impl;

import com.bblocks.common.anti_reptile.config.bean.RuleComm;
import com.bblocks.common.anti_reptile.constant.RuleResultEnum;
import com.bblocks.common.anti_reptile.constant.RuleTypeEnum;
import com.bblocks.common.anti_reptile.module.MatchResult;
import com.bblocks.common.anti_reptile.service.NoticeService;
import lombok.extern.slf4j.Slf4j;

/**
 * <p>Project: bb-anti-reptile - NoticeServiceImplDefault</p>
 * <p>描述：默认通知结果-只是记录日志</p>
 *
 * @Author Zhao [125043150@qq.com]
 * @Date 2024/4/16 10:19
 * @Version 1.0
 * @since 8
 */
@Slf4j
public class NoticeServiceImplDefault implements NoticeService {

    @Override
    public void onLimiterEvent(final MatchResult matchResult) {
        if(log.isDebugEnabled())
            log.debug("规则：{}，锁定规则:{}（{}）  涉嫌id：{}（url:{}），预计锁定时间：{}",matchResult.getMatchRule().getRuleTypeEnum().getDesc()
                    , RuleResultEnum.getRuleResult(matchResult.getMatchRule().getLockType()).getDesc(), matchResult.getMatchRule().getLockType(),matchResult.getId(),matchResult.getUrl()
                    ,matchResult.getMatchRule().getLockExpire());
    }

    @Override
    public void onBlackOverEvent(final MatchResult matchResult) {
        if(log.isDebugEnabled())
            log.debug("规则：{}，锁定规则:{}（{}）  涉嫌id：{}（url:{}），解锁！",matchResult.getMatchRule().getRuleTypeEnum().getDesc()
                , RuleResultEnum.getRuleResult(matchResult.getMatchRule().getLockType()).getDesc(), matchResult.getMatchRule().getLockType(),matchResult.getId(),matchResult.getUrl());
    }


    @Override
    public int getOrder() {
        return Integer.MAX_VALUE;
    }
}
